package com.setup.trac.controller.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.setup.trac.pojo.TipoIntervento;

public class TipoInterventoValidator implements Validator {

	public boolean supports(Class<?> clazz) {
		return clazz.isAssignableFrom(TipoIntervento.class);
	}

	public void validate(Object target, Errors errors) {
		TipoIntervento tipoIntervento = (TipoIntervento) target;
		if(tipoIntervento.getIdIntervento().toPlainString().equals("-1")){
			errors.rejectValue("idIntervento", "", "Campo obbligatorio");
		}
	}

}
